/**
 * 
 */
package ar.edu.unq.svnpermission.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.uqbar.commons.model.Entity;

/**
 * Representa una estructura de carpetas
 * @author nicolas
 */
public class Folder extends Entity implements Serializable{

	private static final long serialVersionUID = 1L;
	private String name;
	private String comments;
	private Date creationDate;
	private Folder parent;
	private List<Folder> childFolders = new ArrayList<Folder>();

	
	/**
	 * Obtiene el path completo de esta Folder
	 * @return un String que contiene el Path completo del Folder
	 * @author nicolas
	 */
	public String getFullPath()
	{
		String path = this.getName();
		Folder parent = this.getParent();
		while(parent!=null)
		{
			path = parent.getName() + "\\" + path;
			parent = parent.getParent();
		}
		return path;
	}
	
	@Override
	public String toString()
	{
		return this.getName();
	}
	
	public void addChildFolder(Folder folder)
	{
		this.getChildFolders().add(folder);
	}
	
	public void removeChildFolder(Folder folder)
	{
		this.getChildFolders().remove(folder);
	}	
	
	
	//Getters And Setters
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public Date getCreationDate() {
		return creationDate;
	}
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	public Folder getParent() {
		return parent;
	}
	public void setParent(Folder parent) {
		this.parent = parent;
	}
	public List<Folder> getChildFolders() {
		return childFolders;
	}
	public void setChildFolders(List<Folder> childFolders) {
		this.childFolders = childFolders;
	}

}
